<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>7 通常是for...in 和 hasOwnProperty 配合使用</title>
</head>

<body>
  <script>
    let obj = {
      name: "Elisy",
      age: 22,
      0: "variable",
      [Symbol("s1")]: 200,
      [Symbol("s2")]: function () { },
    };

    Object.prototype.AAA = "AAA"

    // 好处：不会遍历到原型上的属性
    for (const key in obj) {
      if (obj.hasOwnProperty(key)) {
        console.log(key)
      }
    }
  </script>
</body>

</html>